package 越短越合法

func countSubarrays(nums []int, k int64) int64 {
	cnt := 0
	s := 0
	left := 0
	for right, num := range nums {
		s += num
		for int64(s*(right-left+1)) >= k {
			s -= nums[left]
			left++
		}
		cnt += right - left + 1
	}
	return int64(cnt)
}
